home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / DATABASE / PUSHBU.ZIP;1 / PUSHDEMO.PRG < prev    next >
Encoding:
Text File  |  1993-06-13  |  5.7 KB  |  153 lines

  1. /*-------------------------------------------------------------------------*
  2.  
  3.     Program...: PUSHDEMO.PRG    PUSHBUTTON DEMO PROGRAM
  4.     Date......: June 12, 1993
  5.     Author....: Wendy Starbuck
  6.  
  7. *--------------------------------------------------------------------------*/
  8.  
  9.  
  10. // Include Standard Headers
  11. #include "pushbutn.ch"                 // Pushbutton headers
  12. #include "inkey.ch"                    // Keypress constants
  13.  
  14. // Define Program Actions
  15. #define  INITIALIZATION       1
  16. #define  OPEN_WINDOW          2
  17. #define  ENTER_UPDATE_DATA    3
  18. #define  SELECT_FILES         4
  19. #define  EXECUTE_BACKUP       5
  20. #define  END_OF_JOB           6
  21. #define  HOUSEKEEPING         7
  22.  
  23. function Main()
  24.  
  25.     // Declare public variables
  26.     memvar GetList
  27.  
  28.     // Declare control variables
  29.     local  lContinue    := .T.         // Continuation status indicator
  30.     local  lAbort       := .F.         // Abort condition flag
  31.     local  nAction      := 1           // Program action pointer
  32.     local  nChoice
  33.     local  cBkUpFrom
  34.     local  cBkUpTo
  35.     local  nBkUpType
  36.     local  nBkUpMethod
  37.     local  cGetColor
  38.  
  39.     // Program control loop
  40.     while lContinue .and. ! lAbort
  41.  
  42.         do case
  43.         case nAction == INITIALIZATION
  44.             SaveEnviron()
  45.             set scoreboard off
  46.             CLS
  47.             cGetColor := substr( ( cGetColor := ColorSet(COL_WIND_STD)),;
  48.                                  1, (at(",",cGetColor)-1 ) )
  49.             SetBlink(.F.)
  50.             cBkUpFrom   := "C:\WORK                 "
  51.             cBkUpTo     := "C:\WORK                 "
  52.             nBkUpType   := 1
  53.             nBkUpMethod := 1
  54.             nChoice     := 1
  55.             nAction     := OPEN_WINDOW
  56.  
  57.         case nAction == OPEN_WINDOW
  58.             Win_Create( 4, 10, 20, 69, ColorSet(COL_WIND_STD), WIN_DUMB_WINDOW )
  59.             Win_Title( "Demo Program - Execute Backup" )
  60.             ColorChg( COL_WIND_STD )
  61.             // WTO, WSAY, WGET just repositions the coordinates within the
  62.             // window, otherwise they are benign
  63.             @ 3,  3 WTO  6, 56
  64.             @ 7,  3 WTO 11, 29
  65.             @ 7, 30 WTO 11, 56
  66.             ColorChg( COL_WIND_TEXT )
  67.             @ 3, 27 WSAY "From/To"
  68.             @ 4,  6 WSAY "Backup from.........:"
  69.             @ 5,  6 WSAY "Backup to...........:"
  70.             @ 7, 10 WSAY "File Selection"
  71.             @ 7, 36 WSAY "Handling Method"
  72.             nAction := ENTER_UPDATE_DATA
  73.  
  74.         case nAction == ENTER_UPDATE_DATA
  75.             Win_Mssg( " This program has no functioning backup routines ! " )
  76.             @ 4, 30 WGET cBkUpFrom ;
  77.                          picture "@! XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
  78.             @ 5, 30 WGET cBkUpTo   ;
  79.                          picture "@! XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
  80.  
  81.             // Radiobuttons from RADIOBTN.PRG by Dan Comeau
  82.             @ 8, 06 WGET nBkUpType                                        ;
  83.                          color cGetColor                                  ;
  84.                          with radiobuttons { "Application files",         ;
  85.                                              "Database files",            ;
  86.                                              "All files"          } nobox
  87.             @ 8, 32 WGET nBkUpMethod                                      ;
  88.                          color cGetColor                                  ;
  89.                          with radiobuttons { "Overwrite files",           ;
  90.                                              "Save files"         } nobox
  91.  
  92.             // Pushbuttons from PUSHBUTN.PRG by Wendy Starbuck
  93.             @13, 07 WGET nChoice                                          ;
  94.                          color ColorSet( COL_WIND_STD )                   ; 
  95.                          start at nChoice                                 ;
  96.                          with pushbuttons { "   Select   ",               ;
  97.                                             "   Backup   ",               ;
  98.                                             "    Quit    "                }
  99.  
  100.             set cursor on
  101.             read
  102.             set cursor off
  103.  
  104.             // Kill buttons
  105.             RadioBtnKill()
  106.             PushBtnKill()
  107.  
  108.             // Handle keypresses
  109.             do case
  110.             // Permit enter or spacebar to execute the buttons
  111.             case LastKey() == K_ENTER .or. ;
  112.                  LastKey() == K_SPACE
  113.                     // Handle button choices
  114.                     do case
  115.                     case nChoice == 1 ; nAction := SELECT_FILES
  116.                     case nChoice == 2 ; nAction := EXECUTE_BACKUP
  117.                     case nChoice == 3 ; nAction := END_OF_JOB
  118.                     endcase
  119.             case LastKey() == K_ESC
  120.                 nAction := END_OF_JOB
  121.             endcase
  122.  
  123.         case nAction == SELECT_FILES
  124.             ActionBox( { "Select Files is not installed!" },, ;
  125.                        SOUND_BEEPER, OK_BUTTON )
  126.             nAction := ENTER_UPDATE_DATA
  127.  
  128.         case nAction == EXECUTE_BACKUP
  129.             ActionBox( { "Execute Backup is not installed!",  ;
  130.                          "Press OK to continue or",           ;
  131.                          "ESCAPE to end it all!" },,          ; 
  132.                        SOUND_BEEPER, OK_BUTTON )
  133.             if Lastkey() == K_ESC
  134.                 nAction := END_OF_JOB
  135.             else
  136.                 nAction := ENTER_UPDATE_DATA
  137.             endif
  138.  
  139.         case nAction == END_OF_JOB
  140.             // Always do your housekeeping
  141.             Win_Kill()
  142.             RestEnviron()
  143.             lContinue := .F.
  144.    
  145.         endcase
  146.  
  147.     end
  148.  
  149. return NIL
  150.  
  151.  
  152. /* EOF: PUSHDEMO.PRG ------------------------------------------------------*/
  153.